<!-- 新增\编辑拓客码 -->
<template>
  <dt-modal-edit
    ref="edit"
    :title="title"
    :loading="loading"
    :label-width="100"
    okText="保存"
    :width="800"
    @ok="onOk"></dt-modal-edit>
</template>

<script>
  import editOpt from '../opt/edit'
  import pointMgr from '@/biz/customerForCode/point'
  export default {
    data() {
      return {
        loading: false,
        title: '新建/编辑拓客码',
        info: {},
        isEdit: false
      }
    },
    methods: {
      show(data) {
        this.isEdit = data.isEdit
        this.title = data.title
        this.info = {
          tokerName: '',
          channelId: '',
          channelName: '',
          ...data
        }
        this.$refs.edit.show()
        this.$refs.edit.show(editOpt.ExpandCodeOpt(this), this.info)
      },
      onOk(data) {
        let params = {
          tokerName: data.tokerName,
          channelId: data.channelId,
          acId: this.$route.query.activityId,
          id: data.tokerId
        }
        pointMgr.createToker(params).then((res) => {
          this.$Message.success('保存成功')
          this.$emit('success')
          this.$refs.edit.hide()
        })
      }
    }
  }
</script>

<style lang="scss" scoped>
  .add_edit_btn {
    color: #0f42a7;
    cursor: pointer;
    margin-right: 10px;
  }
</style>
